package com.tanhua.server.controller;

import com.tanhua.commons.exception.TanHuaException;
import com.tanhua.domain.vo.RecommendVoiceUser;
import com.tanhua.domain.vo.RecommendVoiceUserVo;
import com.tanhua.server.service.VoiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/peachblossom")
public class VoiceController {
    @Autowired
    private VoiceService voiceService;
    /*
    * 发送语音:
    * 前端参数: soundFile
    * 返回数据: 无
    *
    * */
    @RequestMapping(method = RequestMethod.POST)
    public ResponseEntity sendVoice(MultipartFile soundFile) throws IOException {
        // 调用服务: 是否需要判断?
        if(soundFile.isEmpty()){
            throw new TanHuaException("语音为空,发送失败");
        }
        voiceService.sendVoice(soundFile);

        // 返回数据
        return ResponseEntity.ok(null);
    }




}
